#include "Card.h"

#define NUM_DATA 4

static int glob_id = 1;

static const char names[NUM_DATA][NAME_SIZE] = {
    "Pedro",
    "Wilma",
    "Betty",
    "Pablo",
};

static const char nifs[NUM_DATA][NIF_SIZE] = {
    "08277292P",
    "52489618W",
    "45781697B",
    "45781697P",
};

static const int nums_items[NUM_DATA] = { 7, 22, 11, 43 };

static const float costs[NUM_DATA] = {2.43f, 134.97f, 234.197f, 845.248f};

void Card_fill(Card *p_card)
{
    int index = (glob_id - 1) % NUM_DATA;
    *p_card = (Card) {
        .id = glob_id, .n_items = nums_items[index], .cost = costs[index],
    };
    strncpy(p_card->user, names[index], NAME_SIZE);
    strncpy(p_card->nif, nifs[index], NIF_SIZE);
    glob_id += 1;
}

void Card_dump(Card *p_card, char *array)
{
    memcpy(array, p_card, sizeof(Card));
}
